home *** CD-ROM | disk | FTP | other *** search
- Path: dawn.mmm.com!news
- From: kjhopps@mmm.com (Kevin J Hopps)
- Newsgroups: comp.lang.c++
- Subject: Re: copy ctor and derived classes
- Date: 15 Jan 1996 14:26:33 GMT
- Organization: 3M - St. Paul, MN 55144-1000 US
- Message-ID: <4ddo6p$3au@dawn.mmm.com>
- References: <DL38zz.50K@Virginia.EDU> <4d6u37$3b7@news.bridge.net>
- Reply-To: kjhopps@mmm.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- David Byrden (100101.2547@compuserve.com) wrote:
-
- > Greg;
-
- > >> how can I invoke the base class's copy constructor in the
- > >> intialization list the derived class doesn't have to deal
- > >> with all of the little bits of the base class?
-
-
- > The derived class has no RIGHT to deal with all the bits of the
- > base class. They can be private.
-
- > Here's what to do:
-
-
- > Derived::Derived( const Derived& rhs ) // copy ctor
- > : Base( *this ) // invoke base's copy ctor
- > {
-
- > }
-
- Even better would be to use Base(rhs) with instead of Base(*this) :-)
- --
- Kevin J. Hopps e-mail: kjhopps@mmm.com
- 3M Company phone: (612) 737-4643
- 3M Center, Bldg. 235-2D-57 fax: (612) 737-2700
- St. Paul, MN 55144-1000 Opinions are my own. I don't speak for 3M.
- But 3M speaks for me -- I did not write the following line:
-
- Opinions expressed herein are my own and may not represent those of 3M.
-